from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time

# **指定 ChromeDriver 路径**
driver_path = "D:\\桌面\\Application\\chromedriver.exe"
service = Service(driver_path)
driver = webdriver.Chrome(service=service)

# **定义网址**
first_url = "https://www.bilibili.com/"
second_url = "https://www.youku.com/"

# **设置窗口大小**
driver.set_window_size(1200, 800)  # 设置固定大小
# driver.maximize_window()  # 或者最大化

# **打开 B 站**
driver.get(first_url)
print("已打开 B 站")

# **等待 3 秒**
time.sleep(3)

# **打开优酷**
driver.get(second_url)
print("已打开优酷")

# **等待 3 秒**
time.sleep(3)

# **后退到 B 站**
driver.back()
print("后退进入 B 站")

# **等待 3 秒**
time.sleep(3)

# **前进到优酷**
driver.forward()
print("前进进入 Youku")

# **等待 3 秒**
time.sleep(3)

# **关闭浏览器**
driver.quit()